package com.zhaosc.spark

import org.apache.spark.SparkConf
import org.apache.spark.SparkContext

object WordCount {
  def main(args: Array[String]) {
    val conf = new SparkConf().setAppName("WordCount")
      .setMaster("local");
    val sc = new SparkContext(conf)
    val line = sc.textFile("D:\\zhaoshichao\\workspace\\com.zhaosc.spark\\src\\main\\java\\data.txt")
    line.flatMap(_.split(" ")).map((_, 1)).reduceByKey(_ + _).
      collect().foreach(println)
    sc.stop()
  }
}